import Vue from 'vue'
import VueRouter from 'vue-router'

import Home from '../views/home.vue'
import Class from '../views/class.vue'
import Cart from '../views/cart.vue'
import My from '../views/my.vue'
import No from '../views/no404.vue'

import Era from "../views/homes/era.vue"
import Erb from "../views/homes/erb.vue"
import Erc from "../views/homes/erc.vue"
import Erd from "../views/homes/erd.vue"
import Ere from "../views/homes/ere.vue"

import Details from "../views/change/details.vue"

Vue.use(VueRouter)


const originalPush = VueRouter.prototype.push
const originalReplace = VueRouter.prototype.replace

VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}

VueRouter.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
  return originalReplace.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    redirect:"/home"
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
  },
  {
    path: '/class',
    name: 'Class',
    component: Class
  },
  {
    path: '/cart',
    name: 'Cart',
    component: Cart
  },
  {
    path: '/my',
    name: 'My',
    component: My
  },
  {
    path:"/era",
    name:"Era",
    component:Era
  },
  {
    path:"/erb",
    name:"Erb",
    component:Erb
  },
  {
    path:"/erc",
    name:"Erc",
    component:Erc
  },
  {
    path:"/erd",
    name:"Erd",
    component:Erd
  },
  {
    path:"/details",
    name:"Details",
    component:Details
  },
  {
    path:"/ere",
    name:"Ere",
    component:Ere
  },
  {
    path: '*',
    name: 'No',
    component: No
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


export default router
